<template>
  <div class="app-container">
    <div class="head-container">
      <el-input v-model="taskName" clearable placeholder="输入任务名称搜索" maxlength="10" style="width: 200px;"
                class="filter-item" @keyup.enter.native="init"/>
      <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="init">搜索</el-button>
    </div>
    <el-table v-loading="loading" :data="data" size="small" style="width: 100%;" border>
      <el-table-column
        type="index"
        label="序号"
        align="center"
        width="60">
      </el-table-column>
      <el-table-column prop="taskName" label="任务名称"  align="center"/>
      <el-table-column prop="taskName" label="任务进度"  align="center">
        <template slot-scope="scope">
          <el-progress :percentage="(scope.row.finishCount/scope.row.userCount)*100"></el-progress>
        </template>
      </el-table-column>
      <el-table-column prop="userCount" label="参与人数" width="100" align="center"/>
      <el-table-column prop="finishCount" label="完成人数" width="100" align="center"/>
      <el-table-column label="操作" width="100" align="center">
        <template slot-scope="{ row }">
          <el-link type="primary" @click="toInfo(row)" style="font-size: 13px;">查看详情</el-link>
         <!-- <el-divider direction="vertical"/> -->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :total="total"
      :current-page="page + 1"
      style="margin-top: 8px;"
      layout="total, prev, pager, next, sizes"
      @size-change="sizeChange"
      @current-change="pageChange"/>
  </div>
</template>

<script>
  import initData from '@/mixins/initData'

  export default {
    name: 'index',
    mixins: [initData],
    data() {
      return {
        taskName: ''
      }
    },
    created() {
      this.$nextTick(() => {
        this.init()
      })
    },
    methods: {
      beforeInit() {
        this.url = 'task/schedule-list'
        this.params = { page: this.page, size: this.size, taskName: this.taskName }
        return true
      },
      toInfo(row) {
        this.$router.push({
          path: '/home/taskInfo',
          query: { id: row.id }
        })
      }
    }
  }
</script>
